<%--
  Created by IntelliJ IDEA.
  User: 石小俊
  Date: 2024/11/16
  Time: 13:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>商城主页</title>
</head>
<body>
<marquee style="color:red;font-size:40px">欢迎来到紫金购物商城</marquee>
<c:choose>
    <c:when test="${empty user}">
        <a href="${pageContext.request.contextPath}/jsp/register.jsp">注册</a>
        <a href="${pageContext.request.contextPath}/jsp/login.jsp">登录</a>
    </c:when>
    <c:otherwise>
        欢迎您:${user.username}
        <a href="${pageContext.request.contextPath}/logout.user">注销</a>
        <a href="${pageContext.request.contextPath}/myOrders.order">我的订单</a>
    </c:otherwise>
</c:choose>
当前在线人数:${count}
<hr>
<table border="1">
    <tr>
        <th>序号</th>
        <th>商品名称</th>
        <th>商品单价</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${products}" var="product">
        <tr>
            <td>${product.id}</td>
            <td>${product.name}</td>
            <td>${product.price}</td>
            <td><a href="${pageContext.request.contextPath}/add.cart?id=${product.id}">加入购物车</a></td>
        </tr>
    </c:forEach>
</table>
<a href="${pageContext.request.contextPath}/jsp/cart.jsp">查看购物车</a><br>
<span style="color:red;">${productMsg}</span>
</body>
</html>
